package com.view.inventtorymanage;

import com.bean.Customer;
import com.bean.Power;
import com.bean.Stock;
import com.lovo.netCRM.component.LovoButton;
import com.service.*;
import com.service.impl.*;
import com.view.MainFrame;
import com.view.jurisdictionmanage.RoleShowDialog;
import com.view.resourcemanage.CustomerFrame.CustomerShowDialog;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;

public class StockShowDialog extends JDialog {

    private LovoButton addBtn;
    private LovoButton cancelBtn;
    private JLabel nameTxt,directorTxt,telTxt,emailTxt,addressTxt,rangeTxt;


    private MainFrame frame ;
    private int key;
    private StockService stockService = new StockServiceImpl();

    public StockShowDialog(MainFrame frame,int key) {
        // TODO Auto-generated constructor stub
        super(frame,"商品详情",true);
        this.frame = frame;
        this.key = key;
        this.setBounds(350, 250, 520, 400);
        this.setLayout(null);
        this.init();
        this.setVisible(true);

    }



    private void init() {
        // TODO Auto-generated method stub
        Stock stock = new Stock();
        stock = stockService.showStock(key);


        nameTxt = new JLabel();
        nameTxt.setBounds(20,20,150,60);
        nameTxt.setText("<html>商品名："+stock.getGoods().getName()+" </html>");
        this.add(nameTxt);

        directorTxt = new JLabel();
        directorTxt.setBounds(20,90,150,60);
        directorTxt.setText("<html>厂家："+stock.getGoods().getManufactor()+" </html>");
        this.add(directorTxt);

        telTxt = new JLabel();
        telTxt.setBounds(20,160,150,60);
        telTxt.setText("<html>类别："+stock.getGoods().getType()+" </html>");
        this.add(telTxt);

        emailTxt = new JLabel();
        emailTxt.setBounds(300,20,150,60);
        emailTxt.setText("<html>建议采购价："+stock.getGoods().getBuyPrice()+" </html>");
        this.add(emailTxt);


        addressTxt = new JLabel();
        addressTxt.setBounds(300,90,150,60);
        addressTxt.setText("<html>建议销售价："+stock.getGoods().getSellPrice()+" </html>");
        this.add(addressTxt);

        rangeTxt = new JLabel();
        rangeTxt.setBounds(300,160,150,60);
        rangeTxt.setText("<html>数量："+stock.getNumber()+" </html>");
        this.add(rangeTxt);


        this.cancelBtn = new LovoButton("取消", 270, 320, this);

        cancelBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                StockShowDialog.this.dispose();;
            }
        });

    }

}
